package org.dbstar.scheduler.actions;

import java.io.Serializable;

public class AjaxResult implements Serializable {

	private final static int OK = 200;
	private final static int ERROR = 500;

	private int code;
	private String message;
	private Object result;

	public void error(String message) {
		this.code = ERROR;
		this.message = message;
	}

	public void ok(Object result) {
		this.code = OK;
		this.result = result;
	}

	public boolean ok() {
		return code == OK;
	}

	public boolean error() {
		return code != OK && code != 0;
	}

	public int getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	public Object getResult() {
		return result;
	}

}
